package BC54_获得月份天数;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            int year = sc.nextInt();
            int month = sc.nextInt();
            ArrayList<Integer> a = new ArrayList<>();
            Collections.addAll(a, 1, 3, 5, 7, 8, 10 ,12);
            if (a.contains(month)){
                System.out.println(31);
            }else if (month == 2){
                if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)){
                    System.out.println(29);
                }else {
                    System.out.println(28);
                }
            }else {
                System.out.println(30);
            }
        }
    }
}
